<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>anchor analytics</title>
    </head>
    <body>
        <ul>
            <!-- use onlick 
                    or bind click event to all a tag which href start by # -->
            <li><a onclick="trackAnchorView(this)" href="#help">help</a></li>
            <li><a onclick="trackAnchorView(this)" href="#contact">contact</a></li>
        </ul> 
        <p>
        <a name="help"></a>
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        help message<br />
        </p>
        <div><a name="contact"></a>
            contact us ...
        </div>


<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19187512-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

    function trackAnchorView(o){
        var url = o.href;
        url = url.replace(/^http:\/\/[^\/]+/g, '');

        /* google analytics 
           see: http://www.google.com/support/googleanalytics/bin/answer.py?answer=55521 */
        var pageTracker = _gat._getTracker('UA-19187512-1');
        pageTracker._trackPageview(url);
        
        /* custom method */
        trackPageView(url);
    }

/* custom track methods */
var client_id = 'get from cookie'
var _tracker_gif = 'http://localhost/an-empty-gif.gif';
function trackPageView(data){
    if(!data){
        return;
    }

    var url = _tracker_gif
        + '?d=' + escape(data)
        + '&c=' + escape(client_id)
        + '&t=' + (new Date().getTime());


    var img = document.createElement('img');
    img.src = url;
    img.style.width = '1px';
    img.style.height = '1px';
    document.body.appendChild(img);
    img.onload = function(){
        document.body.removeChild(img);
        img = null;
    }
}


</script>


    </body>
</html>
